package net.techwatch.commons.utils;

import java.util.Properties;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSourceFactory;

public class DbUtils {

	public static DataSource createDataSource(String propertiesFile) {
		Properties properties = FileUtils.loadFromClasspath(propertiesFile);
		
		if(properties == null)
			return null;
		
		return createDataSource(properties);
	}
	
	public static DataSource createDataSource(Properties properties) {
		DataSource result = null;
		try {
			result = BasicDataSourceFactory.createDataSource(properties);
			return result;
		} catch(Exception e) {
			return null;
		}
	}
}
